<template>
  <div class="login-container">
    <div class="login-box">
      <h2>登录</h2>
      <input type="text" v-model="username" placeholder="用户名" />
      <input type="password" v-model="password" placeholder="密码" />
      <button @click="login">登录</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: '',
    };
  },
  methods: {
    login() {
      if (this.username === 'admin' && this.password === '123456') {
        this.$router.push('/index');
      } else {
        alert('用户名或密码错误');
      }
    },
  },
};
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-image: url('http://img.netbian.com/file/2024/1005/small234725fjV2b1728143245.jpg');
  background-size: cover;
}

.login-box {
  background-color: rgba(255, 255, 255, 0.5);
  padding: 20px;
  border-radius: 30px;
  text-align: center;
}

input {
  display: block;
  margin: 10px auto;
  padding: 5px;
}

button {
  padding: 5px 20px;
}
</style>
